import { Component } from '@angular/core';

import { Title } from '@angular/platform-browser';

import { HttpClient } from '@angular/common/http';

enum IMG {
  A = 1,
  B
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  // template: `
  //   <h1 [ngStyle]="mystyle" [ngClass]="myclass">{{title}}</h1>
  //   <div [ngClass]="two">
  //     <p class="tc1">123</p>
  //   </div>
  // `,
  styleUrls: ['./app.component.css','./app.component.scss']
  // styles: [
  //   `
  //     .one{
  //       font-size:12px;
  //     }
  //     .two{
  //         color: #df4f5f;
  //     }
  //     .two .tc1 {
  //       text-align: center;
  //     }
  //     .three{
  //       box-shadow: 1px 1px 0 #00ff00;
  //     }
  //   `
  // ]
})

export class AppComponent {

  constructor(private http: HttpClient,private titleService: Title){
    this.config = {
      title : '123',
      body: '345'
    }
    //this.init();
    this.titleService.setTitle('改变页面标题');
  }
  // title = '小程序';
  config = {};
  mystyle = {
    "border": "1px solid red"
  };
  // myclass = "one";
  myclass = {
    one: true,
    three: false
  };

  imgType: IMG = IMG.A;

  myimgsrc = '../assets/1.jpg';

  user = {
    myname : 'admin',
    password: '123',
    sex: '0',
    zu: '0',
    aihao: {
      paobu: false,
      huahua: false,
      lanqiu: false
    },
    jieshao : ''
  };

  getData(){
    return this.http.get('http://rap2api.taobao.org/app/mock/16545/news');
  }
  init(){
    this.getData().subscribe(res=>{
      this.config = res;
    });
  }
  changimg() {
    this.imgType = (this.imgType == IMG.A) ? IMG.B : IMG.A;
    this.myimgsrc = `../assets/${this.imgType}.jpg`;
    this.init();
  }

  mysubmit(){
    // this.user.aihao.paobu = true;
    // this.user.aihao.huahua = false;
    // this.user.aihao.lanqiu = false;
    // console.log(f);
    console.log(this.user);
    // console.log(this.user.aihao);
    // console.log(JSON.stringify(this.user.aihao));
  }

}
